<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>Cheetah Software: rt_spi.h File Reference</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../resize.js"></script>
<script type="text/javascript" src="../../navtreedata.js"></script>
<script type="text/javascript" src="../../navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Cheetah Software
   &#160;<span id="projectnumber">1.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="../../index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="../../namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="../../annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="../../files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="../../search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="../../search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="../../files.html"><span>File&#160;List</span></a></li>
      <li><a href="../../globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('d0/dae/rt__spi_8h.html','../../');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">rt_spi.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &lt;fcntl.h&gt;</code><br />
<code>#include &lt;sys/ioctl.h&gt;</code><br />
<code>#include &lt;linux/spi/spidev.h&gt;</code><br />
<code>#include &lt;stdint.h&gt;</code><br />
<code>#include &lt;stdio.h&gt;</code><br />
<code>#include &lt;stdlib.h&gt;</code><br />
<code>#include &lt;string.h&gt;</code><br />
<code>#include &lt;unistd.h&gt;</code><br />
<code>#include &lt;spi_command_t.hpp&gt;</code><br />
<code>#include &lt;spi_data_t.hpp&gt;</code><br />
<code>#include &lt;spi_torque_t.hpp&gt;</code><br />
</div><div class="textblock"><div id="dynsection-0" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-0-trigger" src="../../closed.png" alt="+"/> Include dependency graph for rt_spi.h:</div>
<div id="dynsection-0-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-0-content" class="dyncontent" style="display:none;">
<div class="center"><img src="../../d4/d61/rt__spi_8h__incl.png" border="0" usemap="#rt__spi_8h" alt=""/></div>
<map name="rt__spi_8h" id="rt__spi_8h">
</map>
</div>
</div><div class="textblock"><div id="dynsection-1" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-1-trigger" src="../../closed.png" alt="+"/> This graph shows which files directly or indirectly include this file:</div>
<div id="dynsection-1-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-1-content" class="dyncontent" style="display:none;">
<div class="center"><img src="../../d5/d8d/rt__spi_8h__dep__incl.png" border="0" usemap="#rt__spi_8hdep" alt=""/></div>
<map name="rt__spi_8hdep" id="rt__spi_8hdep">
</map>
</div>
</div>
<p><a href="../../d0/dae/rt__spi_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/d9e/structspine__cmd__t.html">spine_cmd_t</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../de/de1/structspine__data__t.html">spine_data_t</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:a16e1750a8c350d6bdf5ee34ac1f2b725"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d0/dae/rt__spi_8h.html#a16e1750a8c350d6bdf5ee34ac1f2b725">K_EXPECTED_COMMAND_SIZE</a>&#160;&#160;&#160;256</td></tr>
<tr class="separator:a16e1750a8c350d6bdf5ee34ac1f2b725"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adc2caca9802fd1471258f8fd6a06a727"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d0/dae/rt__spi_8h.html#adc2caca9802fd1471258f8fd6a06a727">K_WORDS_PER_MESSAGE</a>&#160;&#160;&#160;66</td></tr>
<tr class="separator:adc2caca9802fd1471258f8fd6a06a727"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a63377a4b9d48b89d4d14253399f9d3e5"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d0/dae/rt__spi_8h.html#a63377a4b9d48b89d4d14253399f9d3e5">K_EXPECTED_DATA_SIZE</a>&#160;&#160;&#160;116</td></tr>
<tr class="separator:a63377a4b9d48b89d4d14253399f9d3e5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad525a9d72e9a7090f793511248bba3c9"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d0/dae/rt__spi_8h.html#ad525a9d72e9a7090f793511248bba3c9">K_KNEE_OFFSET_POS</a>&#160;&#160;&#160;4.35f</td></tr>
<tr class="separator:ad525a9d72e9a7090f793511248bba3c9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae8b243fdac3715a3da7c98b9a380eaa5"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d0/dae/rt__spi_8h.html#ae8b243fdac3715a3da7c98b9a380eaa5">BYTE_TO_BINARY_PATTERN</a>&#160;&#160;&#160;&quot;%c%c%c%c%c%c%c%c&quot;</td></tr>
<tr class="separator:ae8b243fdac3715a3da7c98b9a380eaa5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa28480bfa03957b4f284c13e800ca8b0"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d0/dae/rt__spi_8h.html#aa28480bfa03957b4f284c13e800ca8b0">BYTE_TO_BINARY</a>(byte)</td></tr>
<tr class="separator:aa28480bfa03957b4f284c13e800ca8b0"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a8eb9780a3438ec02c70314744f91f3c7"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d0/dae/rt__spi_8h.html#a8eb9780a3438ec02c70314744f91f3c7">init_spi</a> ()</td></tr>
<tr class="separator:a8eb9780a3438ec02c70314744f91f3c7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a203bbcc4db5a480dbdf813356e836415"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d0/dae/rt__spi_8h.html#a203bbcc4db5a480dbdf813356e836415">spi_send_receive</a> (spi_command_t *command, spi_data_t *data)</td></tr>
<tr class="separator:a203bbcc4db5a480dbdf813356e836415"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a684e8d785e723147c81388a694a72454"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d0/dae/rt__spi_8h.html#a684e8d785e723147c81388a694a72454">spi_driver_run</a> ()</td></tr>
<tr class="separator:a684e8d785e723147c81388a694a72454"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a86aa57487cebed6685ec3a22729662e6"><td class="memItemLeft" align="right" valign="top">spi_data_t *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d0/dae/rt__spi_8h.html#a86aa57487cebed6685ec3a22729662e6">get_spi_data</a> ()</td></tr>
<tr class="separator:a86aa57487cebed6685ec3a22729662e6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3e61e97e0ec55d0c36c2883793c12c08"><td class="memItemLeft" align="right" valign="top">spi_command_t *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d0/dae/rt__spi_8h.html#a3e61e97e0ec55d0c36c2883793c12c08">get_spi_command</a> ()</td></tr>
<tr class="separator:a3e61e97e0ec55d0c36c2883793c12c08"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Macro Definition Documentation</h2>
<a class="anchor" id="aa28480bfa03957b4f284c13e800ca8b0"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define BYTE_TO_BINARY</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">byte</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<b>Value:</b><div class="fragment"><div class="line">(byte &amp; 0x80 ? <span class="charliteral">&#39;1&#39;</span> : <span class="charliteral">&#39;0&#39;</span>), (byte &amp; 0x40 ? <span class="charliteral">&#39;1&#39;</span> : <span class="charliteral">&#39;0&#39;</span>),     \</div><div class="line">      (byte &amp; 0x20 ? <span class="charliteral">&#39;1&#39;</span> : <span class="charliteral">&#39;0&#39;</span>), (byte &amp; 0x10 ? <span class="charliteral">&#39;1&#39;</span> : <span class="charliteral">&#39;0&#39;</span>), \</div><div class="line">      (byte &amp; 0x08 ? <span class="charliteral">&#39;1&#39;</span> : <span class="charliteral">&#39;0&#39;</span>), (byte &amp; 0x04 ? <span class="charliteral">&#39;1&#39;</span> : <span class="charliteral">&#39;0&#39;</span>), \</div><div class="line">      (byte &amp; 0x02 ? <span class="charliteral">&#39;1&#39;</span> : <span class="charliteral">&#39;0&#39;</span>), (byte &amp; 0x01 ? <span class="charliteral">&#39;1&#39;</span> : <span class="charliteral">&#39;0&#39;</span>)</div></div><!-- fragment -->
<p>Definition at line <a class="el" href="../../d0/dae/rt__spi_8h_source.html#l00033">33</a> of file <a class="el" href="../../d0/dae/rt__spi_8h_source.html">rt_spi.h</a>.</p>

</div>
</div>
<a class="anchor" id="ae8b243fdac3715a3da7c98b9a380eaa5"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define BYTE_TO_BINARY_PATTERN&#160;&#160;&#160;&quot;%c%c%c%c%c%c%c%c&quot;</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Definition at line <a class="el" href="../../d0/dae/rt__spi_8h_source.html#l00032">32</a> of file <a class="el" href="../../d0/dae/rt__spi_8h_source.html">rt_spi.h</a>.</p>

</div>
</div>
<a class="anchor" id="a16e1750a8c350d6bdf5ee34ac1f2b725"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define K_EXPECTED_COMMAND_SIZE&#160;&#160;&#160;256</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Definition at line <a class="el" href="../../d0/dae/rt__spi_8h_source.html#l00027">27</a> of file <a class="el" href="../../d0/dae/rt__spi_8h_source.html">rt_spi.h</a>.</p>

</div>
</div>
<a class="anchor" id="a63377a4b9d48b89d4d14253399f9d3e5"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define K_EXPECTED_DATA_SIZE&#160;&#160;&#160;116</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Definition at line <a class="el" href="../../d0/dae/rt__spi_8h_source.html#l00029">29</a> of file <a class="el" href="../../d0/dae/rt__spi_8h_source.html">rt_spi.h</a>.</p>

</div>
</div>
<a class="anchor" id="ad525a9d72e9a7090f793511248bba3c9"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define K_KNEE_OFFSET_POS&#160;&#160;&#160;4.35f</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Definition at line <a class="el" href="../../d0/dae/rt__spi_8h_source.html#l00030">30</a> of file <a class="el" href="../../d0/dae/rt__spi_8h_source.html">rt_spi.h</a>.</p>

</div>
</div>
<a class="anchor" id="adc2caca9802fd1471258f8fd6a06a727"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define K_WORDS_PER_MESSAGE&#160;&#160;&#160;66</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Definition at line <a class="el" href="../../d0/dae/rt__spi_8h_source.html#l00028">28</a> of file <a class="el" href="../../d0/dae/rt__spi_8h_source.html">rt_spi.h</a>.</p>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="a3e61e97e0ec55d0c36c2883793c12c08"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">spi_command_t* get_spi_command </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Definition at line <a class="el" href="../../d1/d62/rt__spi_8cpp_source.html#l00332">332</a> of file <a class="el" href="../../d1/d62/rt__spi_8cpp_source.html">rt_spi.cpp</a>.</p>

<p>References <a class="el" href="../../d1/d62/rt__spi_8cpp_source.html#l00027">spi_command_drv</a>.</p>
<div class="fragment"><div class="line"><a name="l00332"></a><span class="lineno">  332</span>&#160;                                 {</div><div class="line"><a name="l00333"></a><span class="lineno">  333</span>&#160;  <span class="comment">// printf(&quot;Get spi command\n&quot;);</span></div><div class="line"><a name="l00334"></a><span class="lineno">  334</span>&#160;  <span class="keywordflow">return</span> &amp;<a class="code" href="../../d1/d62/rt__spi_8cpp.html#a212699f517cb5bfb2bd42c24e9396a6b">spi_command_drv</a>;</div><div class="line"><a name="l00335"></a><span class="lineno">  335</span>&#160;}</div><div class="ttc" id="rt__spi_8cpp_html_a212699f517cb5bfb2bd42c24e9396a6b"><div class="ttname"><a href="../../d1/d62/rt__spi_8cpp.html#a212699f517cb5bfb2bd42c24e9396a6b">spi_command_drv</a></div><div class="ttdeci">spi_command_t spi_command_drv</div><div class="ttdef"><b>Definition:</b> <a href="../../d1/d62/rt__spi_8cpp_source.html#l00027">rt_spi.cpp:27</a></div></div>
</div><!-- fragment -->
<p><div id="dynsection-2" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-2-trigger" src="../../closed.png" alt="+"/> Here is the caller graph for this function:</div>
<div id="dynsection-2-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-2-content" class="dyncontent" style="display:none;">
<div class="center"><img src="../../d0/dae/rt__spi_8h_a3e61e97e0ec55d0c36c2883793c12c08_icgraph.png" border="0" usemap="#d0/dae/rt__spi_8h_a3e61e97e0ec55d0c36c2883793c12c08_icgraph" alt=""/></div>
<map name="d0/dae/rt__spi_8h_a3e61e97e0ec55d0c36c2883793c12c08_icgraph" id="d0/dae/rt__spi_8h_a3e61e97e0ec55d0c36c2883793c12c08_icgraph">
</map>
</div>
</p>

</div>
</div>
<a class="anchor" id="a86aa57487cebed6685ec3a22729662e6"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">spi_data_t* get_spi_data </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Definition at line <a class="el" href="../../d1/d62/rt__spi_8cpp_source.html#l00337">337</a> of file <a class="el" href="../../d1/d62/rt__spi_8cpp_source.html">rt_spi.cpp</a>.</p>

<p>References <a class="el" href="../../d1/d62/rt__spi_8cpp_source.html#l00028">spi_data_drv</a>.</p>
<div class="fragment"><div class="line"><a name="l00337"></a><span class="lineno">  337</span>&#160;{ <span class="keywordflow">return</span> &amp;<a class="code" href="../../d1/d62/rt__spi_8cpp.html#ad5ebd4dd94dc79364380958849464508">spi_data_drv</a>; }</div><div class="ttc" id="rt__spi_8cpp_html_ad5ebd4dd94dc79364380958849464508"><div class="ttname"><a href="../../d1/d62/rt__spi_8cpp.html#ad5ebd4dd94dc79364380958849464508">spi_data_drv</a></div><div class="ttdeci">spi_data_t spi_data_drv</div><div class="ttdef"><b>Definition:</b> <a href="../../d1/d62/rt__spi_8cpp_source.html#l00028">rt_spi.cpp:28</a></div></div>
</div><!-- fragment -->
<p><div id="dynsection-3" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-3-trigger" src="../../closed.png" alt="+"/> Here is the caller graph for this function:</div>
<div id="dynsection-3-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-3-content" class="dyncontent" style="display:none;">
<div class="center"><img src="../../d0/dae/rt__spi_8h_a86aa57487cebed6685ec3a22729662e6_icgraph.png" border="0" usemap="#d0/dae/rt__spi_8h_a86aa57487cebed6685ec3a22729662e6_icgraph" alt=""/></div>
<map name="d0/dae/rt__spi_8h_a86aa57487cebed6685ec3a22729662e6_icgraph" id="d0/dae/rt__spi_8h_a86aa57487cebed6685ec3a22729662e6_icgraph">
</map>
</div>
</p>

</div>
</div>
<a class="anchor" id="a8eb9780a3438ec02c70314744f91f3c7"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void init_spi </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Definition at line <a class="el" href="../../d1/d62/rt__spi_8cpp_source.html#l00110">110</a> of file <a class="el" href="../../d1/d62/rt__spi_8cpp_source.html">rt_spi.cpp</a>.</p>

<p>References <a class="el" href="../../d0/dae/rt__spi_8h_source.html#l00027">K_EXPECTED_COMMAND_SIZE</a>, <a class="el" href="../../d0/dae/rt__spi_8h_source.html#l00029">K_EXPECTED_DATA_SIZE</a>, <a class="el" href="../../d1/d62/rt__spi_8cpp_source.html#l00027">spi_command_drv</a>, <a class="el" href="../../d1/d62/rt__spi_8cpp_source.html#l00028">spi_data_drv</a>, <a class="el" href="../../d1/d62/rt__spi_8cpp_source.html#l00031">spi_mutex</a>, and <a class="el" href="../../d1/d62/rt__spi_8cpp_source.html#l00137">spi_open()</a>.</p>
<div class="fragment"><div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;                {</div><div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;  <span class="comment">// check sizes:</span></div><div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;  <span class="keywordtype">size_t</span> command_size = <span class="keyword">sizeof</span>(spi_command_t);</div><div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;  <span class="keywordtype">size_t</span> data_size = <span class="keyword">sizeof</span>(spi_data_t);</div><div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;</div><div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;  memset(&amp;<a class="code" href="../../d1/d62/rt__spi_8cpp.html#a212699f517cb5bfb2bd42c24e9396a6b">spi_command_drv</a>, 0, <span class="keyword">sizeof</span>(<a class="code" href="../../d1/d62/rt__spi_8cpp.html#a212699f517cb5bfb2bd42c24e9396a6b">spi_command_drv</a>));</div><div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;  memset(&amp;<a class="code" href="../../d1/d62/rt__spi_8cpp.html#ad5ebd4dd94dc79364380958849464508">spi_data_drv</a>, 0, <span class="keyword">sizeof</span>(<a class="code" href="../../d1/d62/rt__spi_8cpp.html#ad5ebd4dd94dc79364380958849464508">spi_data_drv</a>));</div><div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;</div><div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;  <span class="keywordflow">if</span> (pthread_mutex_init(&amp;<a class="code" href="../../d1/d62/rt__spi_8cpp.html#ad2b0c4c0380cc217d458a4f849dec246">spi_mutex</a>, NULL) != 0)</div><div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;    printf(<span class="stringliteral">&quot;[ERROR: RT SPI] Failed to create spi data mutex\n&quot;</span>);</div><div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;</div><div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;  <span class="keywordflow">if</span> (command_size != <a class="code" href="../../d0/dae/rt__spi_8h.html#a16e1750a8c350d6bdf5ee34ac1f2b725">K_EXPECTED_COMMAND_SIZE</a>) {</div><div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;    printf(<span class="stringliteral">&quot;[RT SPI] Error command size is %ld, expected %d\n&quot;</span>, command_size,</div><div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;           <a class="code" href="../../d0/dae/rt__spi_8h.html#a16e1750a8c350d6bdf5ee34ac1f2b725">K_EXPECTED_COMMAND_SIZE</a>);</div><div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;  } <span class="keywordflow">else</span></div><div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;    printf(<span class="stringliteral">&quot;[RT SPI] command size good\n&quot;</span>);</div><div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;</div><div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;  <span class="keywordflow">if</span> (data_size != <a class="code" href="../../d0/dae/rt__spi_8h.html#a63377a4b9d48b89d4d14253399f9d3e5">K_EXPECTED_DATA_SIZE</a>) {</div><div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;    printf(<span class="stringliteral">&quot;[RT SPI] Error data size is %ld, expected %d\n&quot;</span>, data_size,</div><div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;           <a class="code" href="../../d0/dae/rt__spi_8h.html#a63377a4b9d48b89d4d14253399f9d3e5">K_EXPECTED_DATA_SIZE</a>);</div><div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;  } <span class="keywordflow">else</span></div><div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;    printf(<span class="stringliteral">&quot;[RT SPI] data size good\n&quot;</span>);</div><div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;</div><div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;  printf(<span class="stringliteral">&quot;[RT SPI] Open\n&quot;</span>);</div><div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;  <a class="code" href="../../d1/d62/rt__spi_8cpp.html#a10dc9dfda11e6d6371d59bb609ba6996">spi_open</a>();</div><div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;}</div><div class="ttc" id="rt__spi_8h_html_a16e1750a8c350d6bdf5ee34ac1f2b725"><div class="ttname"><a href="../../d0/dae/rt__spi_8h.html#a16e1750a8c350d6bdf5ee34ac1f2b725">K_EXPECTED_COMMAND_SIZE</a></div><div class="ttdeci">#define K_EXPECTED_COMMAND_SIZE</div><div class="ttdef"><b>Definition:</b> <a href="../../d0/dae/rt__spi_8h_source.html#l00027">rt_spi.h:27</a></div></div>
<div class="ttc" id="rt__spi_8h_html_a63377a4b9d48b89d4d14253399f9d3e5"><div class="ttname"><a href="../../d0/dae/rt__spi_8h.html#a63377a4b9d48b89d4d14253399f9d3e5">K_EXPECTED_DATA_SIZE</a></div><div class="ttdeci">#define K_EXPECTED_DATA_SIZE</div><div class="ttdef"><b>Definition:</b> <a href="../../d0/dae/rt__spi_8h_source.html#l00029">rt_spi.h:29</a></div></div>
<div class="ttc" id="rt__spi_8cpp_html_ad2b0c4c0380cc217d458a4f849dec246"><div class="ttname"><a href="../../d1/d62/rt__spi_8cpp.html#ad2b0c4c0380cc217d458a4f849dec246">spi_mutex</a></div><div class="ttdeci">pthread_mutex_t spi_mutex</div><div class="ttdef"><b>Definition:</b> <a href="../../d1/d62/rt__spi_8cpp_source.html#l00031">rt_spi.cpp:31</a></div></div>
<div class="ttc" id="rt__spi_8cpp_html_ad5ebd4dd94dc79364380958849464508"><div class="ttname"><a href="../../d1/d62/rt__spi_8cpp.html#ad5ebd4dd94dc79364380958849464508">spi_data_drv</a></div><div class="ttdeci">spi_data_t spi_data_drv</div><div class="ttdef"><b>Definition:</b> <a href="../../d1/d62/rt__spi_8cpp_source.html#l00028">rt_spi.cpp:28</a></div></div>
<div class="ttc" id="rt__spi_8cpp_html_a10dc9dfda11e6d6371d59bb609ba6996"><div class="ttname"><a href="../../d1/d62/rt__spi_8cpp.html#a10dc9dfda11e6d6371d59bb609ba6996">spi_open</a></div><div class="ttdeci">int spi_open()</div><div class="ttdef"><b>Definition:</b> <a href="../../d1/d62/rt__spi_8cpp_source.html#l00137">rt_spi.cpp:137</a></div></div>
<div class="ttc" id="rt__spi_8cpp_html_a212699f517cb5bfb2bd42c24e9396a6b"><div class="ttname"><a href="../../d1/d62/rt__spi_8cpp.html#a212699f517cb5bfb2bd42c24e9396a6b">spi_command_drv</a></div><div class="ttdeci">spi_command_t spi_command_drv</div><div class="ttdef"><b>Definition:</b> <a href="../../d1/d62/rt__spi_8cpp_source.html#l00027">rt_spi.cpp:27</a></div></div>
</div><!-- fragment -->
<p><div id="dynsection-4" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-4-trigger" src="../../closed.png" alt="+"/> Here is the call graph for this function:</div>
<div id="dynsection-4-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-4-content" class="dyncontent" style="display:none;">
<div class="center"><img src="../../d0/dae/rt__spi_8h_a8eb9780a3438ec02c70314744f91f3c7_cgraph.png" border="0" usemap="#d0/dae/rt__spi_8h_a8eb9780a3438ec02c70314744f91f3c7_cgraph" alt=""/></div>
<map name="d0/dae/rt__spi_8h_a8eb9780a3438ec02c70314744f91f3c7_cgraph" id="d0/dae/rt__spi_8h_a8eb9780a3438ec02c70314744f91f3c7_cgraph">
</map>
</div>
</p>

<p><div id="dynsection-5" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-5-trigger" src="../../closed.png" alt="+"/> Here is the caller graph for this function:</div>
<div id="dynsection-5-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-5-content" class="dyncontent" style="display:none;">
<div class="center"><img src="../../d0/dae/rt__spi_8h_a8eb9780a3438ec02c70314744f91f3c7_icgraph.png" border="0" usemap="#d0/dae/rt__spi_8h_a8eb9780a3438ec02c70314744f91f3c7_icgraph" alt=""/></div>
<map name="d0/dae/rt__spi_8h_a8eb9780a3438ec02c70314744f91f3c7_icgraph" id="d0/dae/rt__spi_8h_a8eb9780a3438ec02c70314744f91f3c7_icgraph">
</map>
</div>
</p>

</div>
</div>
<a class="anchor" id="a684e8d785e723147c81388a694a72454"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void spi_driver_run </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Definition at line <a class="el" href="../../d1/d62/rt__spi_8cpp_source.html#l00319">319</a> of file <a class="el" href="../../d1/d62/rt__spi_8cpp_source.html">rt_spi.cpp</a>.</p>

<p>References <a class="el" href="../../d1/d62/rt__spi_8cpp_source.html#l00062">fake_spine_control()</a>, <a class="el" href="../../dd/ddf/rt__spi__lcm_8cpp_source.html#l00016">publish_spi_torque()</a>, <a class="el" href="../../d1/d62/rt__spi_8cpp_source.html#l00027">spi_command_drv</a>, <a class="el" href="../../d1/d62/rt__spi_8cpp_source.html#l00028">spi_data_drv</a>, <a class="el" href="../../d1/d62/rt__spi_8cpp_source.html#l00031">spi_mutex</a>, <a class="el" href="../../d1/d62/rt__spi_8cpp_source.html#l00260">spi_send_receive()</a>, and <a class="el" href="../../d1/d62/rt__spi_8cpp_source.html#l00029">spi_torque</a>.</p>
<div class="fragment"><div class="line"><a name="l00319"></a><span class="lineno">  319</span>&#160;                      {</div><div class="line"><a name="l00320"></a><span class="lineno">  320</span>&#160;  <span class="comment">// do spi board calculations</span></div><div class="line"><a name="l00321"></a><span class="lineno">  321</span>&#160;  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; 4; i++) {</div><div class="line"><a name="l00322"></a><span class="lineno">  322</span>&#160;    <a class="code" href="../../d1/d62/rt__spi_8cpp.html#a8e068bf4eccc8576a64472a3ab648bc5">fake_spine_control</a>(&amp;<a class="code" href="../../d1/d62/rt__spi_8cpp.html#a212699f517cb5bfb2bd42c24e9396a6b">spi_command_drv</a>, &amp;<a class="code" href="../../d1/d62/rt__spi_8cpp.html#ad5ebd4dd94dc79364380958849464508">spi_data_drv</a>, &amp;<a class="code" href="../../d1/d62/rt__spi_8cpp.html#a1225355baf64e608a9d905c4b77df2ff">spi_torque</a>, i);</div><div class="line"><a name="l00323"></a><span class="lineno">  323</span>&#160;  }</div><div class="line"><a name="l00324"></a><span class="lineno">  324</span>&#160;  <a class="code" href="../../d7/d47/rt__spi__lcm_8h.html#a8793654fc8604008f59e9fdb0ed3ad5c">publish_spi_torque</a>(&amp;<a class="code" href="../../d1/d62/rt__spi_8cpp.html#a1225355baf64e608a9d905c4b77df2ff">spi_torque</a>);</div><div class="line"><a name="l00325"></a><span class="lineno">  325</span>&#160;</div><div class="line"><a name="l00326"></a><span class="lineno">  326</span>&#160;  <span class="comment">// in here, the driver is good</span></div><div class="line"><a name="l00327"></a><span class="lineno">  327</span>&#160;  pthread_mutex_lock(&amp;<a class="code" href="../../d1/d62/rt__spi_8cpp.html#ad2b0c4c0380cc217d458a4f849dec246">spi_mutex</a>);</div><div class="line"><a name="l00328"></a><span class="lineno">  328</span>&#160;  <a class="code" href="../../d1/d62/rt__spi_8cpp.html#a203bbcc4db5a480dbdf813356e836415">spi_send_receive</a>(&amp;<a class="code" href="../../d1/d62/rt__spi_8cpp.html#a212699f517cb5bfb2bd42c24e9396a6b">spi_command_drv</a>, &amp;<a class="code" href="../../d1/d62/rt__spi_8cpp.html#ad5ebd4dd94dc79364380958849464508">spi_data_drv</a>);</div><div class="line"><a name="l00329"></a><span class="lineno">  329</span>&#160;  pthread_mutex_unlock(&amp;<a class="code" href="../../d1/d62/rt__spi_8cpp.html#ad2b0c4c0380cc217d458a4f849dec246">spi_mutex</a>);</div><div class="line"><a name="l00330"></a><span class="lineno">  330</span>&#160;}</div><div class="ttc" id="rt__spi_8cpp_html_a203bbcc4db5a480dbdf813356e836415"><div class="ttname"><a href="../../d1/d62/rt__spi_8cpp.html#a203bbcc4db5a480dbdf813356e836415">spi_send_receive</a></div><div class="ttdeci">void spi_send_receive(spi_command_t *command, spi_data_t *data)</div><div class="ttdef"><b>Definition:</b> <a href="../../d1/d62/rt__spi_8cpp_source.html#l00260">rt_spi.cpp:260</a></div></div>
<div class="ttc" id="rt__spi__lcm_8h_html_a8793654fc8604008f59e9fdb0ed3ad5c"><div class="ttname"><a href="../../d7/d47/rt__spi__lcm_8h.html#a8793654fc8604008f59e9fdb0ed3ad5c">publish_spi_torque</a></div><div class="ttdeci">void publish_spi_torque(spi_torque_t *data)</div><div class="ttdef"><b>Definition:</b> <a href="../../dd/ddf/rt__spi__lcm_8cpp_source.html#l00016">rt_spi_lcm.cpp:16</a></div></div>
<div class="ttc" id="rt__spi_8cpp_html_ad2b0c4c0380cc217d458a4f849dec246"><div class="ttname"><a href="../../d1/d62/rt__spi_8cpp.html#ad2b0c4c0380cc217d458a4f849dec246">spi_mutex</a></div><div class="ttdeci">pthread_mutex_t spi_mutex</div><div class="ttdef"><b>Definition:</b> <a href="../../d1/d62/rt__spi_8cpp_source.html#l00031">rt_spi.cpp:31</a></div></div>
<div class="ttc" id="rt__spi_8cpp_html_a8e068bf4eccc8576a64472a3ab648bc5"><div class="ttname"><a href="../../d1/d62/rt__spi_8cpp.html#a8e068bf4eccc8576a64472a3ab648bc5">fake_spine_control</a></div><div class="ttdeci">void fake_spine_control(spi_command_t *cmd, spi_data_t *data, spi_torque_t *torque_out, int board_num)</div><div class="ttdef"><b>Definition:</b> <a href="../../d1/d62/rt__spi_8cpp_source.html#l00062">rt_spi.cpp:62</a></div></div>
<div class="ttc" id="rt__spi_8cpp_html_a1225355baf64e608a9d905c4b77df2ff"><div class="ttname"><a href="../../d1/d62/rt__spi_8cpp.html#a1225355baf64e608a9d905c4b77df2ff">spi_torque</a></div><div class="ttdeci">spi_torque_t spi_torque</div><div class="ttdef"><b>Definition:</b> <a href="../../d1/d62/rt__spi_8cpp_source.html#l00029">rt_spi.cpp:29</a></div></div>
<div class="ttc" id="rt__spi_8cpp_html_ad5ebd4dd94dc79364380958849464508"><div class="ttname"><a href="../../d1/d62/rt__spi_8cpp.html#ad5ebd4dd94dc79364380958849464508">spi_data_drv</a></div><div class="ttdeci">spi_data_t spi_data_drv</div><div class="ttdef"><b>Definition:</b> <a href="../../d1/d62/rt__spi_8cpp_source.html#l00028">rt_spi.cpp:28</a></div></div>
<div class="ttc" id="rt__spi_8cpp_html_a212699f517cb5bfb2bd42c24e9396a6b"><div class="ttname"><a href="../../d1/d62/rt__spi_8cpp.html#a212699f517cb5bfb2bd42c24e9396a6b">spi_command_drv</a></div><div class="ttdeci">spi_command_t spi_command_drv</div><div class="ttdef"><b>Definition:</b> <a href="../../d1/d62/rt__spi_8cpp_source.html#l00027">rt_spi.cpp:27</a></div></div>
</div><!-- fragment -->
<p><div id="dynsection-6" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-6-trigger" src="../../closed.png" alt="+"/> Here is the call graph for this function:</div>
<div id="dynsection-6-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-6-content" class="dyncontent" style="display:none;">
<div class="center"><img src="../../d0/dae/rt__spi_8h_a684e8d785e723147c81388a694a72454_cgraph.png" border="0" usemap="#d0/dae/rt__spi_8h_a684e8d785e723147c81388a694a72454_cgraph" alt=""/></div>
<map name="d0/dae/rt__spi_8h_a684e8d785e723147c81388a694a72454_cgraph" id="d0/dae/rt__spi_8h_a684e8d785e723147c81388a694a72454_cgraph">
</map>
</div>
</p>

<p><div id="dynsection-7" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-7-trigger" src="../../closed.png" alt="+"/> Here is the caller graph for this function:</div>
<div id="dynsection-7-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-7-content" class="dyncontent" style="display:none;">
<div class="center"><img src="../../d0/dae/rt__spi_8h_a684e8d785e723147c81388a694a72454_icgraph.png" border="0" usemap="#d0/dae/rt__spi_8h_a684e8d785e723147c81388a694a72454_icgraph" alt=""/></div>
<map name="d0/dae/rt__spi_8h_a684e8d785e723147c81388a694a72454_icgraph" id="d0/dae/rt__spi_8h_a684e8d785e723147c81388a694a72454_icgraph">
</map>
</div>
</p>

</div>
</div>
<a class="anchor" id="a203bbcc4db5a480dbdf813356e836415"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void spi_send_receive </td>
          <td>(</td>
          <td class="paramtype">spi_command_t *&#160;</td>
          <td class="paramname"><em>command</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">spi_data_t *&#160;</td>
          <td class="paramname"><em>data</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Definition at line <a class="el" href="../../d1/d62/rt__spi_8cpp_source.html#l00260">260</a> of file <a class="el" href="../../d1/d62/rt__spi_8cpp_source.html">rt_spi.cpp</a>.</p>

<p>References <a class="el" href="../../d0/dae/rt__spi_8h_source.html#l00028">K_WORDS_PER_MESSAGE</a>, <a class="el" href="../../d1/d62/rt__spi_8cpp_source.html#l00019">spi_1_fd</a>, <a class="el" href="../../d1/d62/rt__spi_8cpp_source.html#l00020">spi_2_fd</a>, <a class="el" href="../../d1/d62/rt__spi_8cpp_source.html#l00015">spi_bits_per_word</a>, <a class="el" href="../../d1/d62/rt__spi_8cpp_source.html#l00186">spi_driver_iterations</a>, <a class="el" href="../../d1/d62/rt__spi_8cpp_source.html#l00189">spi_to_spine()</a>, and <a class="el" href="../../d1/d62/rt__spi_8cpp_source.html#l00235">spine_to_spi()</a>.</p>
<div class="fragment"><div class="line"><a name="l00260"></a><span class="lineno">  260</span>&#160;                                                                {</div><div class="line"><a name="l00261"></a><span class="lineno">  261</span>&#160;  <span class="comment">// update driver status flag</span></div><div class="line"><a name="l00262"></a><span class="lineno">  262</span>&#160;  <a class="code" href="../../d1/d62/rt__spi_8cpp.html#ae8f69f94e245c5175e96b2f3838685b0">spi_driver_iterations</a>++;</div><div class="line"><a name="l00263"></a><span class="lineno">  263</span>&#160;  data-&gt;spi_driver_status = <a class="code" href="../../d1/d62/rt__spi_8cpp.html#ae8f69f94e245c5175e96b2f3838685b0">spi_driver_iterations</a> &lt;&lt; 16;</div><div class="line"><a name="l00264"></a><span class="lineno">  264</span>&#160;</div><div class="line"><a name="l00265"></a><span class="lineno">  265</span>&#160;  <span class="comment">// transmit and receive buffers</span></div><div class="line"><a name="l00266"></a><span class="lineno">  266</span>&#160;  uint16_t tx_buf[<a class="code" href="../../d0/dae/rt__spi_8h.html#adc2caca9802fd1471258f8fd6a06a727">K_WORDS_PER_MESSAGE</a>];</div><div class="line"><a name="l00267"></a><span class="lineno">  267</span>&#160;  uint16_t rx_buf[<a class="code" href="../../d0/dae/rt__spi_8h.html#adc2caca9802fd1471258f8fd6a06a727">K_WORDS_PER_MESSAGE</a>];</div><div class="line"><a name="l00268"></a><span class="lineno">  268</span>&#160;</div><div class="line"><a name="l00269"></a><span class="lineno">  269</span>&#160;  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> spi_board = 0; spi_board &lt; 2; spi_board++) {</div><div class="line"><a name="l00270"></a><span class="lineno">  270</span>&#160;    <span class="comment">// copy command into spine type:</span></div><div class="line"><a name="l00271"></a><span class="lineno">  271</span>&#160;    <a class="code" href="../../d1/d62/rt__spi_8cpp.html#acc45f58dc7a8bffa48be85ef06e03309">spi_to_spine</a>(command, &amp;<a class="code" href="../../d1/d62/rt__spi_8cpp.html#ab0513fd20c12aea68c75f0ac0e66db63">g_spine_cmd</a>, spi_board * 2);</div><div class="line"><a name="l00272"></a><span class="lineno">  272</span>&#160;</div><div class="line"><a name="l00273"></a><span class="lineno">  273</span>&#160;    <span class="comment">// pointers to command/data spine array</span></div><div class="line"><a name="l00274"></a><span class="lineno">  274</span>&#160;    uint16_t *cmd_d = (uint16_t *)&amp;<a class="code" href="../../d1/d62/rt__spi_8cpp.html#ab0513fd20c12aea68c75f0ac0e66db63">g_spine_cmd</a>;</div><div class="line"><a name="l00275"></a><span class="lineno">  275</span>&#160;    uint16_t *data_d = (uint16_t *)&amp;<a class="code" href="../../d1/d62/rt__spi_8cpp.html#a1f4dd1dcb93301e0fbb6d1d04681afc0">g_spine_data</a>;</div><div class="line"><a name="l00276"></a><span class="lineno">  276</span>&#160;</div><div class="line"><a name="l00277"></a><span class="lineno">  277</span>&#160;    <span class="comment">// zero rx buffer</span></div><div class="line"><a name="l00278"></a><span class="lineno">  278</span>&#160;    memset(rx_buf, 0, <a class="code" href="../../d0/dae/rt__spi_8h.html#adc2caca9802fd1471258f8fd6a06a727">K_WORDS_PER_MESSAGE</a> * <span class="keyword">sizeof</span>(uint16_t));</div><div class="line"><a name="l00279"></a><span class="lineno">  279</span>&#160;</div><div class="line"><a name="l00280"></a><span class="lineno">  280</span>&#160;    <span class="comment">// copy into tx buffer flipping bytes</span></div><div class="line"><a name="l00281"></a><span class="lineno">  281</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; <a class="code" href="../../d0/dae/rt__spi_8h.html#adc2caca9802fd1471258f8fd6a06a727">K_WORDS_PER_MESSAGE</a>; i++)</div><div class="line"><a name="l00282"></a><span class="lineno">  282</span>&#160;      tx_buf[i] = (cmd_d[i] &gt;&gt; 8) + ((cmd_d[i] &amp; 0xff) &lt;&lt; 8);</div><div class="line"><a name="l00283"></a><span class="lineno">  283</span>&#160;    <span class="comment">// tx_buf[i] = __bswap_16(cmd_d[i]);</span></div><div class="line"><a name="l00284"></a><span class="lineno">  284</span>&#160;</div><div class="line"><a name="l00285"></a><span class="lineno">  285</span>&#160;    <span class="comment">// each word is two bytes long</span></div><div class="line"><a name="l00286"></a><span class="lineno">  286</span>&#160;    <span class="keywordtype">size_t</span> word_len = 2;  <span class="comment">// 16 bit word</span></div><div class="line"><a name="l00287"></a><span class="lineno">  287</span>&#160;</div><div class="line"><a name="l00288"></a><span class="lineno">  288</span>&#160;    <span class="comment">// spi message struct</span></div><div class="line"><a name="l00289"></a><span class="lineno">  289</span>&#160;    <span class="keyword">struct </span>spi_ioc_transfer spi_message[1];</div><div class="line"><a name="l00290"></a><span class="lineno">  290</span>&#160;</div><div class="line"><a name="l00291"></a><span class="lineno">  291</span>&#160;    <span class="comment">// zero message struct.</span></div><div class="line"><a name="l00292"></a><span class="lineno">  292</span>&#160;    memset(spi_message, 0, 1 * <span class="keyword">sizeof</span>(<span class="keyword">struct</span> spi_ioc_transfer));</div><div class="line"><a name="l00293"></a><span class="lineno">  293</span>&#160;</div><div class="line"><a name="l00294"></a><span class="lineno">  294</span>&#160;    <span class="comment">// set up message struct</span></div><div class="line"><a name="l00295"></a><span class="lineno">  295</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; 1; i++) {</div><div class="line"><a name="l00296"></a><span class="lineno">  296</span>&#160;      spi_message[i].bits_per_word = <a class="code" href="../../d1/d62/rt__spi_8cpp.html#a80fda0db57659f3b440d379fbfd41a45">spi_bits_per_word</a>;</div><div class="line"><a name="l00297"></a><span class="lineno">  297</span>&#160;      spi_message[i].cs_change = 1;</div><div class="line"><a name="l00298"></a><span class="lineno">  298</span>&#160;      spi_message[i].delay_usecs = 0;</div><div class="line"><a name="l00299"></a><span class="lineno">  299</span>&#160;      spi_message[i].len = word_len * 66;</div><div class="line"><a name="l00300"></a><span class="lineno">  300</span>&#160;      spi_message[i].rx_buf = (uint64_t)rx_buf;</div><div class="line"><a name="l00301"></a><span class="lineno">  301</span>&#160;      spi_message[i].tx_buf = (uint64_t)tx_buf;</div><div class="line"><a name="l00302"></a><span class="lineno">  302</span>&#160;    }</div><div class="line"><a name="l00303"></a><span class="lineno">  303</span>&#160;</div><div class="line"><a name="l00304"></a><span class="lineno">  304</span>&#160;    <span class="comment">// do spi communication</span></div><div class="line"><a name="l00305"></a><span class="lineno">  305</span>&#160;    <span class="keywordtype">int</span> rv = ioctl(spi_board == 0 ? <a class="code" href="../../d1/d62/rt__spi_8cpp.html#a57c6f94391b401d4ad7d4a30c7904e73">spi_1_fd</a> : <a class="code" href="../../d1/d62/rt__spi_8cpp.html#a072f113863622b6852dcc6af85b875ed">spi_2_fd</a>, SPI_IOC_MESSAGE(1),</div><div class="line"><a name="l00306"></a><span class="lineno">  306</span>&#160;                   &amp;spi_message);</div><div class="line"><a name="l00307"></a><span class="lineno">  307</span>&#160;    (void)rv;</div><div class="line"><a name="l00308"></a><span class="lineno">  308</span>&#160;</div><div class="line"><a name="l00309"></a><span class="lineno">  309</span>&#160;    <span class="comment">// flip bytes the other way</span></div><div class="line"><a name="l00310"></a><span class="lineno">  310</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; 30; i++)</div><div class="line"><a name="l00311"></a><span class="lineno">  311</span>&#160;      data_d[i] = (rx_buf[i] &gt;&gt; 8) + ((rx_buf[i] &amp; 0xff) &lt;&lt; 8);</div><div class="line"><a name="l00312"></a><span class="lineno">  312</span>&#160;    <span class="comment">// data_d[i] = __bswap_16(rx_buf[i]);</span></div><div class="line"><a name="l00313"></a><span class="lineno">  313</span>&#160;</div><div class="line"><a name="l00314"></a><span class="lineno">  314</span>&#160;    <span class="comment">// copy back to data</span></div><div class="line"><a name="l00315"></a><span class="lineno">  315</span>&#160;    <a class="code" href="../../d1/d62/rt__spi_8cpp.html#a884cb6c718f657f5aeef5e8b1b5619b7">spine_to_spi</a>(data, &amp;<a class="code" href="../../d1/d62/rt__spi_8cpp.html#a1f4dd1dcb93301e0fbb6d1d04681afc0">g_spine_data</a>, spi_board * 2);</div><div class="line"><a name="l00316"></a><span class="lineno">  316</span>&#160;  }</div><div class="line"><a name="l00317"></a><span class="lineno">  317</span>&#160;}</div><div class="ttc" id="rt__spi_8cpp_html_a1f4dd1dcb93301e0fbb6d1d04681afc0"><div class="ttname"><a href="../../d1/d62/rt__spi_8cpp.html#a1f4dd1dcb93301e0fbb6d1d04681afc0">g_spine_data</a></div><div class="ttdeci">static spine_data_t g_spine_data</div><div class="ttdef"><b>Definition:</b> <a href="../../d1/d62/rt__spi_8cpp_source.html#l00025">rt_spi.cpp:25</a></div></div>
<div class="ttc" id="rt__spi_8cpp_html_a80fda0db57659f3b440d379fbfd41a45"><div class="ttname"><a href="../../d1/d62/rt__spi_8cpp.html#a80fda0db57659f3b440d379fbfd41a45">spi_bits_per_word</a></div><div class="ttdeci">unsigned char spi_bits_per_word</div><div class="ttdef"><b>Definition:</b> <a href="../../d1/d62/rt__spi_8cpp_source.html#l00015">rt_spi.cpp:15</a></div></div>
<div class="ttc" id="rt__spi_8cpp_html_a072f113863622b6852dcc6af85b875ed"><div class="ttname"><a href="../../d1/d62/rt__spi_8cpp.html#a072f113863622b6852dcc6af85b875ed">spi_2_fd</a></div><div class="ttdeci">int spi_2_fd</div><div class="ttdef"><b>Definition:</b> <a href="../../d1/d62/rt__spi_8cpp_source.html#l00020">rt_spi.cpp:20</a></div></div>
<div class="ttc" id="rt__spi_8cpp_html_a884cb6c718f657f5aeef5e8b1b5619b7"><div class="ttname"><a href="../../d1/d62/rt__spi_8cpp.html#a884cb6c718f657f5aeef5e8b1b5619b7">spine_to_spi</a></div><div class="ttdeci">void spine_to_spi(spi_data_t *data, spine_data_t *spine_data, int leg_0)</div><div class="ttdef"><b>Definition:</b> <a href="../../d1/d62/rt__spi_8cpp_source.html#l00235">rt_spi.cpp:235</a></div></div>
<div class="ttc" id="rt__spi_8h_html_adc2caca9802fd1471258f8fd6a06a727"><div class="ttname"><a href="../../d0/dae/rt__spi_8h.html#adc2caca9802fd1471258f8fd6a06a727">K_WORDS_PER_MESSAGE</a></div><div class="ttdeci">#define K_WORDS_PER_MESSAGE</div><div class="ttdef"><b>Definition:</b> <a href="../../d0/dae/rt__spi_8h_source.html#l00028">rt_spi.h:28</a></div></div>
<div class="ttc" id="rt__spi_8cpp_html_ab0513fd20c12aea68c75f0ac0e66db63"><div class="ttname"><a href="../../d1/d62/rt__spi_8cpp.html#ab0513fd20c12aea68c75f0ac0e66db63">g_spine_cmd</a></div><div class="ttdeci">static spine_cmd_t g_spine_cmd</div><div class="ttdef"><b>Definition:</b> <a href="../../d1/d62/rt__spi_8cpp_source.html#l00024">rt_spi.cpp:24</a></div></div>
<div class="ttc" id="rt__spi_8cpp_html_ae8f69f94e245c5175e96b2f3838685b0"><div class="ttname"><a href="../../d1/d62/rt__spi_8cpp.html#ae8f69f94e245c5175e96b2f3838685b0">spi_driver_iterations</a></div><div class="ttdeci">int spi_driver_iterations</div><div class="ttdef"><b>Definition:</b> <a href="../../d1/d62/rt__spi_8cpp_source.html#l00186">rt_spi.cpp:186</a></div></div>
<div class="ttc" id="rt__spi_8cpp_html_acc45f58dc7a8bffa48be85ef06e03309"><div class="ttname"><a href="../../d1/d62/rt__spi_8cpp.html#acc45f58dc7a8bffa48be85ef06e03309">spi_to_spine</a></div><div class="ttdeci">void spi_to_spine(spi_command_t *cmd, spine_cmd_t *spine_cmd, int leg_0)</div><div class="ttdef"><b>Definition:</b> <a href="../../d1/d62/rt__spi_8cpp_source.html#l00189">rt_spi.cpp:189</a></div></div>
<div class="ttc" id="rt__spi_8cpp_html_a57c6f94391b401d4ad7d4a30c7904e73"><div class="ttname"><a href="../../d1/d62/rt__spi_8cpp.html#a57c6f94391b401d4ad7d4a30c7904e73">spi_1_fd</a></div><div class="ttdeci">int spi_1_fd</div><div class="ttdef"><b>Definition:</b> <a href="../../d1/d62/rt__spi_8cpp_source.html#l00019">rt_spi.cpp:19</a></div></div>
</div><!-- fragment -->
<p><div id="dynsection-8" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-8-trigger" src="../../closed.png" alt="+"/> Here is the call graph for this function:</div>
<div id="dynsection-8-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-8-content" class="dyncontent" style="display:none;">
<div class="center"><img src="../../d0/dae/rt__spi_8h_a203bbcc4db5a480dbdf813356e836415_cgraph.png" border="0" usemap="#d0/dae/rt__spi_8h_a203bbcc4db5a480dbdf813356e836415_cgraph" alt=""/></div>
<map name="d0/dae/rt__spi_8h_a203bbcc4db5a480dbdf813356e836415_cgraph" id="d0/dae/rt__spi_8h_a203bbcc4db5a480dbdf813356e836415_cgraph">
</map>
</div>
</p>

<p><div id="dynsection-9" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-9-trigger" src="../../closed.png" alt="+"/> Here is the caller graph for this function:</div>
<div id="dynsection-9-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-9-content" class="dyncontent" style="display:none;">
<div class="center"><img src="../../d0/dae/rt__spi_8h_a203bbcc4db5a480dbdf813356e836415_icgraph.png" border="0" usemap="#d0/dae/rt__spi_8h_a203bbcc4db5a480dbdf813356e836415_icgraph" alt=""/></div>
<map name="d0/dae/rt__spi_8h_a203bbcc4db5a480dbdf813356e836415_icgraph" id="d0/dae/rt__spi_8h_a203bbcc4db5a480dbdf813356e836415_icgraph">
</map>
</div>
</p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="../../dir_43e0a1f539e00dcfa1a6bc4d4fee4fc2.html">home</a></li><li class="navelem"><a class="el" href="../../dir_61bfb0b3cdda81b1b0355ba34eb3b1eb.html">dhkim</a></li><li class="navelem"><a class="el" href="../../dir_adee5b101e079090017bb4e91c628ead.html">Public_Repository</a></li><li class="navelem"><a class="el" href="../../dir_7fc07a7b97001e7b1d18e11da761e2de.html">Cheetah-Software</a></li><li class="navelem"><a class="el" href="../../dir_e69772fee2c25f3f3a3da98250dcdda2.html">robot</a></li><li class="navelem"><a class="el" href="../../dir_20818e807e73f5841d8cf65b57c69c9c.html">include</a></li><li class="navelem"><a class="el" href="../../dir_6844cdb0195786a1ce825e66a22893fa.html">rt</a></li><li class="navelem"><a class="el" href="../../d0/dae/rt__spi_8h.html">rt_spi.h</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="../../doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
  </ul>
</div>
</body>
</html>
